package com.bindatax.core.statistics;

public class ExecuteStatistics {
    private long time;
    private int read = 0;
    private int write = 0;
    private int input = 0;
    private int output = 0;
    private int update = 0;
    private int reject = 0;
    private int error = 0;

    public ExecuteStatistics(){
        clear();
    }

    public int getRead() {
        return read;
    }

    public void setRead(int read) {
        this.read = read;
    }

    public int getWrite() {
        return write;
    }

    public void setWrite(int write) {
        this.write = write;
    }

    public int getInput() {
        return input;
    }

    public void setInput(int input) {
        this.input = input;
    }

    public int getOutput() {
        return output;
    }

    public void setOutput(int output) {
        this.output = output;
    }

    public int getUpdate() {
        return update;
    }

    public void setUpdate(int update) {
        this.update = update;
    }

    public int getReject() {
        return reject;
    }

    public void setReject(int reject) {
        this.reject = reject;
    }

    public int getError() {
        return error;
    }

    public void setError(int error) {
        this.error = error;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public void clear(){
        read = 0;
        write = 0;
        input = 0;
        output = 0;
        update = 0;
        reject = 0;
        error = 0;
        time = System.currentTimeMillis();
    }

    public void copy(ExecuteStatistics outValue){
        if(outValue == null){
            return;
        }
        this.read = outValue.read;
        this.write = outValue.write;
        this.input = outValue.input;
        this.output = outValue.output;
        this.update = outValue.update;
        this.reject = outValue.reject;
        this.error = outValue.error;
        this.time = outValue.time;
    }

    public void addValue(ExecuteStatistics outValue){
        if(outValue == null){
            return;
        }
        this.read += outValue.read;
        this.write += outValue.write;
        this.input += outValue.input;
        this.output += outValue.output;
        this.update += outValue.update;
        this.reject += outValue.reject;
        this.error += outValue.error;
        this.time = System.currentTimeMillis();
    }

    public String descStatisticsInfo(){
        return String.format("入库统计信息：读取%s条，写入%s条，输入%s条，输出%s条，更新%s条，拒绝%s条，错误%s条",
                read,write,input,output,update,reject,error);
    }

}
